@extends('admin::layouts.master')
@section('content')
    <div class="modal-header">
        <h3 id="ModalLabel">{{ $title }}</h3>
    </div>
    <div class="modal-header">
        {{ Form::open(array( 'url' => $packageAdmin.'/admin/product',
                             'method'  => 'post',
                             'role'    => 'form' ,
                             'class'   => 'form-inline'))}}
             <div class="form-group">
                 {{ Form::input('text', 'keySearch', $data['keySearch'], array('placeholder' => 'Product name | mode', 'class' => 'form-control')) }}
             </div>
             <div class="form-group">
                 {{ Form::select('manufacturer_id', array(0 => 'Manufacturer') + $manufacturer, $data['manufacturer_id'], array('class' => 'form-control')) }}
             </div>

             <div class="form-group">
                 {{ Form::select('category_id', array(0 => 'Category') + $category, $data['category_id'], array('class' => 'form-control')) }}
             </div>

             {{ Form::reset('Reset', array('class' => 'btn btn-default')) }}
             {{ Form::submit('Search', array('class' => 'btn btn-primary')) }}

        {{ Form::close()}}
    </div>
    <div class="modal-body">
        <div class="table-responsive">
            @if (Session::has('flash_error'))
            <div id="flash_error">{{ Session::get('flash_error') }}</div>
            @endif
            {{ $products->links() }}
          <table class="table table-bordered table-striped table-hover">
              <tr>
                  <th>Id</th>
                  <th>Model</th>
                  <th>Product name</th>
                  <th>Main image </th>
                  <th>Manufacturer</th>
                  <th>Category</th>
                  <th>Price</th>
                  <th>Quantity</th>
                  <th width="130px">Updated</th>
                  <th>Status</th>
                  <th></th>
              </tr>
            @foreach($products as $key => $product)
                <tr class="@if ($product->status) 'info' @else 'warning' @endif ">
                    <td>{{ $key + 1; }}</td>
                    <td>{{ $product->product_model}}</td>
                    <td>{{ $product->product_name }}</td>
                    <td>
                        <a class="product" href="{{ URL::to('/public').'/'.$product->product_image_main }}">
                            {{ HTML::image(URL::to('/public').'/'.$product->product_image_thumbnail, '', array('width' => '90')) }}
                        </a>
                    </td>
                    <td>{{ $product->manufacturer->manufacturer_name }}</td>
                    <td>{{ $product->category->category_name }}</td>
                    <td>{{ $product->product_price }}</td>
                    <td>{{ $product->product_quantity }}</td>
                    <td>{{ date('F j, Y, g:i A', strtotime($product->updated_at)) }}</td>
                    <td>{{  HTML::image(URL::to('/public').($product->status ? '/images/active.png' : '/images/inactive.png'), '', array('width' => '16', 'class' => 'status', 'data-id' => $product->id, 'data-model' => 'product'));}}</td>
                    <td>
                        {{ html_entity_decode(HTML::linkRoute('product/edit', HTML::image(URL::to('/public/images/edit.png'), '', array('width' => '16')), array('id' => $product->id))) }}
                        {{ html_entity_decode(HTML::linkRoute('product/delete', HTML::image(URL::to('/public/images/delete.gif'), '', array('width' => '16')), array('id' => $product->id))) }}
                        {{ html_entity_decode(HTML::linkRoute('product/view', HTML::image(URL::to('/public/images/view.gif'), '', array('width' => '16')), array('id' => $product->id))) }}
                    </td>
                </tr>
            @endforeach
          </table>
            {{ $products->links() }}
        </div>
    </div>
    <div class="modal-footer">
    </div>
@stop